﻿using BonjourQuotation.DataAccess.Repositories;
using BonjourQuotation.ObjectModel.AccountData;
using BonjourQuotation.ObjectModel.ErrorData;
using BonjourQuotation.ObjectModel.OptionalData;
using BonjourQuotation.ObjectModel.LoggerData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace BonjourQuotation.UI.ServiceManagers
{
    public class OptionalManager
    {
        private readonly log4net.ILog logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        public ErrorBInfo CreateOptional(OptionalDetailsBData OptionalData)
        {
            try
            {
                var proxy = new OptionalRepository();
                return proxy.CreateOptional(OptionalData);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public ErrorBInfo CreateOptionalDetailData(OptionalDetailsBData OptionalData)
        {
            try
            {
                var proxy = new OptionalRepository();
                return proxy.CreateOptionalDetailData(OptionalData);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public ManageOptionalsGridBData LoadAllOptionals(int PageNumber)
        {
            try
            {
                var proxy = new OptionalRepository();
                return proxy.LoadAllOptionals(PageNumber);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public ManageOptionalsGridBData LoadSearchedOptionals(ManageOptionalsGridBData Data)
        {
            try
            {
                var proxy = new OptionalRepository();
                return proxy.LoadSearchedOptionals(Data);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OptionalDetailsBData LoadOptionalDetailsByID(int OptionalID)
        {
            try
            {
                var proxy = new OptionalRepository();
                return proxy.LoadOptionalDetailsByID(OptionalID);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public ErrorBInfo SaveOptionalsGridData(ManageOptionalsGridBData Data)
        {
            try
            {
                var proxy = new OptionalRepository();
                return proxy.SaveOptionalsGridData(Data);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public ErrorBInfo SaveOptionalDetailsData(OptionalDetailsBData Data)
        {
            try
            {
                var proxy = new OptionalRepository();
                return proxy.SaveOptionalDetailsData(Data);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
    }
}